package com.offcn;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;

import java.util.HashMap;
import java.util.Map;

public class smsSendTest {

    public static void main(String[] args) throws Exception {
     //定义短信网关url地址
        String host="http://dingxin.market.alicloudapi.com";
        //定义短信接口访问路径
        String path="/dx/sendSms";
        //定义http请求方法
        String method="POST";
        //身份验证码 appcode
        String appcode="7c177174fe0a45beb43860e61905ffd5";

        //创建一个map集合，封装请求头数据
        Map<String,String> heads=new HashMap<String, String>();
        //把身份验证请求头封装到请求头map
        heads.put("Authorization","APPCODE "+appcode);

        //创建一个map集合，封装请求参数
        Map<String,String> querys=new HashMap<String, String>();
        //要接收手机号码
        querys.put("mobile","13521281544");
        //模板编号
        querys.put("tpl_id","TP1711063");
        //模板的值
        querys.put("param","code:88888");

        //创建一个map集合，封装请求体
        Map<String,String> bodys=new HashMap<String, String>();

        //调用HttpUtis工具类，进行短信发送
        HttpResponse response = HttpUtils.doPost(host, path, method, heads, querys, bodys);

        System.out.println("短信发送:"+response.toString());
        HttpEntity entity = response.getEntity();

        System.out.println(EntityUtils.toString(entity));
    }

    public void test1111(){
        System.out.println("新增测试访问dadadad");
    }
}
